package com.huanghuai.retail.controller;

import com.huanghuai.retail.common.R;
import com.huanghuai.retail.entity.Factory;
import com.huanghuai.retail.service.FactoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/factory")
public class FactoryController {

    @Autowired
    private FactoryService factoryService;

    /**
     * 查询所有厂家
     * @return
     */
    @GetMapping("/findAll")
    public R<List<Factory>> findAllFactory(){
        List<Factory> factoryList = factoryService.list();
        if(factoryList.size()==0){
            return R.error("所有厂家都已清空");
        }
        return R.success(factoryList);
    }
    
    
}
